from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
driver.maximize_window()

time.sleep(2)

# 匹配hao123这个链接的文本
input = driver.find_element(By.XPATH, '//a[contains(text(),"hao")]')
print(input.get_attribute('outerHTML'))

# 匹配标签属性的值
input2 = driver.find_element(By.XPATH, '//*[contains(@id,"k")]')
print(input2.get_attribute('outerHTML'))
